const PAGE_INDICATOR_FADE_TIME = 200;
const PAGE_PREVIEW_RATIO = 0.20;
+const OVERSHOOT_THRESHOLD = 20;
const OVERSHOOT_TIMEOUT = 300;
const DELAYED_MOVE_TIMEOUT = 200;
this._overshootTimeoutId = 0;
}
+ _dragWithinOvershootRegion(dragEvent) {
+ const rtl = this.get_text_direction() === Clutter.TextDirection.RTL;
+ const {x, y, targetActor: indicator} = dragEvent;
+ const [indicatorX, indicatorY] = indicator.get_transformed_position();
+ const [indicatorWidth, indicatorHeight] = indicator.get_transformed_size();
+
+ let overshootX = indicatorX;
+ if (indicator === this._nextPageIndicator || rtl)
+ overshootX += indicatorWidth - OVERSHOOT_THRESHOLD;
+
+ const overshootBox = new Clutter.ActorBox();
+ overshootBox.set_origin(overshootX, indicatorY);
+ overshootBox.set_size(OVERSHOOT_THRESHOLD, indicatorHeight);
+
+ return overshootBox.contains(x, y);
+ }
+
_handleDragOvershoot(dragEvent) {
// Already animating
if (this._adjustment.get_transition('value') !== null)
if (targetPage < 0 || targetPage >= this._grid.nPages)
return; // don't go beyond first/last page
+ // If dragging over the drag overshoot threshold region, immediately
+ // switch pages
+ if (this._dragWithinOvershootRegion(dragEvent)) {
+ this._resetOvershoot();
+ this.goToPage(targetPage);
+ }
+
this._overshootTimeoutId =
GLib.timeout_add(GLib.PRIORITY_DEFAULT, OVERSHOOT_TIMEOUT, () => {
this._resetOvershoot();